#include <iostream>
using namespace std;

bool judge(int x)
{
    if (x % 7 == 0)
    {
        return true;
    }

    while (x)
    {
        if (x % 10 == 7)
        {
            return true;
        }
        x /= 10;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    int num = 0;
    for (int i = 7; i < n; ++i)
    {
        if (judge(i))
        {
            num++;
        }
    }
    cout << num;
    return 0;
}